package com.hnevc.yourhealthmanager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnevc.yourhealthmanager.entity.FoodMeta;
import com.hnevc.yourhealthmanager.entity.HealthPlane;
import com.hnevc.yourhealthmanager.dao.HealthPlaneMapper;
import com.hnevc.yourhealthmanager.service.HealthPlaneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class HealthPlaneServiceImpl extends ServiceImpl<HealthPlaneMapper, HealthPlane> implements HealthPlaneService {
    @Autowired
    HealthPlaneMapper healthPlaneMapper;
    @Override
    public List<HealthPlane> getHealthPlaneByUserId(Integer userId) {
        return healthPlaneMapper.selectByUserId(userId);
    }

    @Override
    public HealthPlane updatePic(Integer id, String filePath) {
        HealthPlane healthPlane= healthPlaneMapper.selectById(id);
        healthPlane.setPlaneImage(filePath);
        if(healthPlaneMapper.updateById(healthPlane)>0){
            return healthPlane;
        }else{
            return null;
        }
    }
}
